home *** CD-ROM | disk | FTP | other *** search
- Path: mail2news.demon.co.uk!genesis.demon.co.uk
- From: Lawrence Kirby <fred@genesis.demon.co.uk>
- Newsgroups: comp.lang.c
- Subject: Re: a question (timing routine)
- Date: Sat, 17 Feb 96 22:44:01 GMT
- Organization: none
- Message-ID: <824597041snz@genesis.demon.co.uk>
- References: <4fvse1$656@pollux.usc.edu>
- Reply-To: fred@genesis.demon.co.uk
- X-NNTP-Posting-Host: genesis.demon.co.uk
- X-Newsreader: Demon Internet Simple News v1.27
- X-Mail2News-Path: genesis.demon.co.uk
-
- In article <4fvse1$656@pollux.usc.edu> separk@pollux.usc.edu "S. Park" writes:
-
- >Hello,
- >
- >I would like to measure time taken for two different implementations
- >of merge sort. I know I can use command "time", but I wonder if
- >anyone can give me some simple example code that uses "time" function
- >in C program so that I can modify it in my comparison.
-
- clock() is the normal function to use for this e.g.
-
- #include <stdio.h>
- #include <time.h>
-
- ...
-
- {
- clock_t start, end;
- ...
- start = clock();
-
- /* Put code to be timed here */
-
- end = clock();
-
- printf("Time taken is %f seconds\n", (end-start) / (double)CLOCKS_PER_SEC);
- ...
- }
-
- --
- -----------------------------------------
- Lawrence Kirby | fred@genesis.demon.co.uk
- Wilts, England | 70734.126@compuserve.com
- -----------------------------------------
-